//
//  BaseTableViewController.swift
//  swift微博
//
//  Created by CC on 16/2/26.
//  Copyright © 2016年 CC. All rights reserved.
//

import UIKit

   class BaseTableViewController : UITableViewController {
//            func cregisterButtonClick(){
//                print("注册")
//            }
//            func cloginButtonClick(){
//                print("登录")
//            }
    var userLogin = false
    
    // 当用户没有登录,使用自定义的界面,如果用户登录了就走父类的流程
    override func loadView() {
        userLogin ? super.loadView() : setupVistorView()
    }
    
    //设置访客视图
    func setupVistorView() {
        self.view = VistorView
        
        VistorView.VistorButtonDelegate = self
        
        if self is HomeViewController {
            VistorView.iconViewRolation()
        }else if (self is MessageViewController){
            VistorView.setUpVistorView("visitordiscover_image_message", labelText: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        } else if(self is DiscoveryViewController){
            VistorView.setUpVistorView("visitordiscover_image_message", labelText: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        }else if(self is ProfileViewController){
            VistorView.setUpVistorView("visitordiscover_image_profile", labelText: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
                
        }
        //设置导航栏//因为navigation controller是一个容器，所以他得控件在子控制器里设置
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "cregisterButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "cloginButtonClick")
            
}

    
    
    //MARK: -懒加载访客View
    lazy var VistorView: VistView = VistView()
}


    //MARK:-代理协议
     extension BaseTableViewController : VistorViewDelegate {
      //代理方法实现
        func cregisterButtonClick(){
            let networkTool = NetWorkTool.sharedInstance
            
        }
        func cloginButtonClick(){
            let OAuthVC:OAuthViewController = OAuthViewController()
            
            presentViewController(UINavigationController(rootViewController: OAuthVC), animated: true, completion: nil)
            
        }
}


